﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Akiha.Core
{
    public static class MathWrapper
    {
        /// <summary>
        /// 将字符串前面的0去掉,格式成整形
        /// </summary>
        public static int FormatStringToIntByDelFirstZero(string value)
        {
            int num;
            foreach (char a in value)
            {
                if (a == '0')
                {
                    value = value.Substring(1);
                }
                if (a != '0')
                {
                    break;
                }
            }
            if (value == "")
            {
                num = 0;
            }
            else
            {
                num = Convert.ToInt32(value);
            }

            return num;
        }

        public static string FormatIntToStringAddZero(string value, int length)
        {
            string str = "";
            int addZeroNum = length - value.Length;
            for (int i = 0; i < addZeroNum; i++)
            {
                str += "0";
            }
            str += value.ToString();
            return str;
        }
    }
}
